#! /bin/sh
# initd script for OpenSuSE 10.x
# Copyright (c) 2005-2007 Jan Willamowius
#
# Note: On Suse 10.2, you should use the tradional network management using ifup.
#       Otherwise not all networks cards seem to be initialized once GnuGk starts.
#
# /etc/init.d/gnugk
#
### BEGIN INIT INFO
# Provides:         	gnugk
# Required-Start:       $local_fs $remote_fs $network 
# X-UnitedLinux-Should-Start:   postgresql mysql sshd
# Required-Stop:        $local_fs $remote_fs $network
# X-UnitedLinux-Should-Stop:    
# Default-Start:        3 5
# Default-Stop:         0 1 2 6
# Short-Description:    GNU Gatekeeper
# Description:          Start the GNU Gatekeeper
### END INIT INFO

. /etc/rc.status
rc_reset

# The echo return value for success (defined in /etc/rc.config).
return=$rc_done
case "$1" in
    start)
	echo -n "Starting GNU Gatekeeper"
	## Start daemon with startproc(8). If this fails
	## the echo return value is set appropriate.

	startproc -q /usr/local/bin/gnugk -c /etc/gatekeeper.ini -tt -o /var/log/gnugk.log
	rc_status -v
	;;
    stop)
	echo -n "Shutting down GNU Gatekeeper"
	## Stop daemon with killproc(8) and if this fails
	## set echo the echo return value.

	killproc -TERM /usr/local/bin/gnugk
	rc_status -v
	;;
    restart)
	## If first returns OK call the second, if first or
	## second command fails, set echo return value.
	$0 stop  &&  $0 start  ||  return=$rc_failed
	;;
    reload)
	$0 stop  &&  $0 start  ||  return=$rc_failed
	;;
    status)
	echo -n "Checking for GNU Gatekeeper: "
	## Check status with checkproc(8), if process is running
	## checkproc will return with exit status 0.

	checkproc /usr/local/bin/gnugk
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart|reload}"
	exit 1
	;;
esac

# Inform the caller not only verbosely and set an exit status.
test "$return" = "$rc_done" || exit 1
exit 0
